import axios from '@/utils/request';
export async function goodsList(params) {
  const res = await axios.post('/goods/goodsList', params);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function add(params) {
  const res = await axios.post('/goods/add', params);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function del(id) {
  const res = await axios.delete('/goods/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 导入用户
 * @param file excel文件
 */
export async function batchGoods(params) {
  const res = await axios.post('/goods/batchGoods', params);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
